# 根据grade排序
classes = [
    {"name": "n_1", "age": 24, "grade": "A"},
    {"name": "n_2", "age": 23, "grade": "B"},
    {"name": "n_3", "age": 28, "grade": "A"},
    {"name": "n_4", "age": 24, "grade": "A"},
    {"name": "n_5", "age": 25, "grade": "C"},
    {"name": "n_6", "age": 21, "grade": "D"},
    {"name": "n_7", "age": 27, "grade": "A"},
]
classes.sort(key=lambda x: x.get("grade"))
print(classes)

# 筛选grade为A的同学
f = filter(lambda x: True if x.get("grade") == "A" else False, classes)
print(list(f))

# age + 1
m = map(lambda x: x.get("age") + 1, classes)
print(list(m))


# 递归函数
def f(n):
    if n == 1:
        return 0
    elif n == 2:
        return 1
    else:
        return f(n - 1) + f(n - 2)


for i in range(1, 13):
    print(f(i))